package com.lagou.service.impl;

import com.lagou.dao.ResumeDao;
import com.lagou.pojo.Resume;
import com.lagou.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("resumeService")
@Transactional
public class ResumeServiceImpl implements ResumeService {

    @Autowired
    private ResumeDao resumeDao;

    /**
     * 查找所有简历
     *
     * @return
     */
    @Override
    @Transactional(readOnly = true)
    public List<Resume> getResumeList() {
        return resumeDao.findAll();
    }

    /**
     * 根据id查找简历
     *
     * @param id
     * @return
     */
    @Override
    @Transactional(readOnly = true)
    public Resume getResume(Long id) {
        return resumeDao.findById(id).get();
    }

    /**
     * 新增/修改简历
     *
     * @param resume
     */
    @Override
    public void saveResume(Resume resume) {
        resumeDao.save(resume);
    }

    /**
     * 删除简历
     *
     * @param id
     */
    @Override
    public void deleteResume(Long id) {
        resumeDao.deleteById(id);
    }
}
